package com.chengqs.test.dubbo.service;

import com.chengqs.rapid.client.RapidInvoker;
import com.chengqs.rapid.client.RapidProtocol;
import com.chengqs.rapid.client.RapidService;
import org.apache.dubbo.config.annotation.Service;

/**
 * <B>主类名称：</B>HelloServiceImpl<BR>
 * <B>概要说明：</B>enter<BR>
 *
 * @author: chengqs
 * @create: 2025-03-16 21:43:07
 **/
@RapidService(serviceId = "say", patternPath = "/say*/**", protocol = RapidProtocol.DUBBO)
@Service(timeout = 3000)
public class HelloServiceImpl implements HelloService {

    private volatile int count;

    @RapidInvoker(path = "/sayHelloUser/c")
    @Override
    public User sayHelloUser(String name) {
        User user = new User();
        user.setName(name);

        count++;
        if(count >= 100000) {
            System.err.println("<------ sayHelloUser.testParam收到请求, name:" + name + " ------>");
            count = 0;
        }
        // System.err.println("3 sayHelloUser(String name): "
        // + FastJsonConvertUtil.convertObjectToJSON(user));
        return user;
    }

    @RapidInvoker(path = "/sayHelloUser/b")
    @Override
    public User sayHelloUser(User user, String name) {
        user.setName(name);
        // System.err.println("2 sayHelloUser(User user, String name): "
        // + FastJsonConvertUtil.convertObjectToJSON(user));
        return user;
    }

    @RapidInvoker(path = "/sayHelloUser/a")
    @Override
    public User sayHelloUser(User user) {
        // System.err.println("1 sayHelloUser(User user): "
        // + FastJsonConvertUtil.convertObjectToJSON(user));
        return user;
    }
}
